﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LIMS.Web
{
    public partial class StuLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }


        protected void ibtnSubmit_Click(object sender, EventArgs e)
        {
            #region 假如浏览器禁用Cookies，则提示用户开启Cookies
            if (Request.Cookies["ValidateCode"] == null)
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('您的浏览器设置已禁用Cookies，您必须启用浏览器的Cookies选项后才能使用本系统!')", true);
                return;
            }
            #endregion

            if (string.Compare(Request.Cookies["ValidateCode"].Value, txtValidate.Text.Trim()) != 0)
            {
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('验证码错误!')", true);
                return;
            }

            Model.Students stuTmp = new Model.Students() { stuNo = txtStudentID.Text.Trim() };

            List<Model.Students> students = BLL.StudentManager.SearchStudent(stuTmp);
            if (students.Count < 1)
            {
                lblError.InnerText = "用户名或密码错误！";
                return;
            }
            Session["studentID"] = txtStudentID.Text.Trim();
            Response.Redirect("StuProject.aspx");
        }

    }
}